﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using CameraService;
using PluginService.DB.Service;
using PluginService.DB.Model;
using PluginService.Common;
using System.IO;
using System.Net;
using PluginService.Common.Model;

namespace Test
{
    public class DisplayAndAlarmConfig
    {
        public string CameraId { get; set; }

        public int FaceDeteiveAlgorithmType { get; set; }

        public string DisplayServer { get; set; }

        public int DisplayServerPort { get; set; }

        public string AlarmServer { get; set; }

        public int AlarmServerPort { get; set; }
    }

    public static class TestDB
    {
        static BlankFeatureService _blankService = new BlankFeatureService();

        public static void Insert()
        {
            BlankFeature feature = new BlankFeature();
            feature.CreateTime = DateTime.Now.ToString();
            feature.Name = "zhansan";
            feature.Feture = new byte[1024];

        }
    }

    class Program
    {
        protected static string _getCameraJsonUrl = "http://127.0.0.1:8080/get_cameras";
        static void Main(string[] args)
        {
            //CreateDisplayAndAlarmConfig();
            //InitCameraService();
            //CreateCameraEngityJson();
            GetCameraJsonFromWebServer();
        }

        static void GetCameraJsonFromWebServer()
        {
            Console.WriteLine(Util.GetJsonFromWeb(_getCameraJsonUrl));
            Console.Read();
        }

        static void CreateDisplayAndAlarmConfig()
        {
            List<DisplayAndAlarmConfig> configs = new List<DisplayAndAlarmConfig>();
            configs.Add(new DisplayAndAlarmConfig() { 
                AlarmServer="127.0.0.1",
                AlarmServerPort=9003,
                CameraId="Camera1",
                DisplayServer="127.0.0.1",
                DisplayServerPort=9004,
                FaceDeteiveAlgorithmType=4
            });
            configs.Add(new DisplayAndAlarmConfig()
            {
                AlarmServer = "127.0.0.1",
                AlarmServerPort = 9003,
                CameraId = "Camera1",
                DisplayServer = "127.0.0.1",
                DisplayServerPort = 9004,
                FaceDeteiveAlgorithmType = 4
            });
            var s = Newtonsoft.Json.JsonConvert.SerializeObject(configs);
            Console.WriteLine(s);
        }

        static void CreateCameraEngityJson()
        {
            List<CameraEntity> _cameraEntitys = new List<CameraEntity>();
            _cameraEntitys.Add(new CameraEntity() { 
                Address="192.168.3.3",
                Id="Camera1",
                PassWord="123456",
                Port=4000,
                TypeId="HIK",
                UserName="admin"
            });
            _cameraEntitys.Add(new CameraEntity()
            {
                Address = "192.168.3.3",
                Id = "Camera1",
                PassWord = "123456",
                Port = 4000,
                TypeId = "HIK",
                UserName = "admin"
            });
            var s = Newtonsoft.Json.JsonConvert.SerializeObject(_cameraEntitys);
            Console.WriteLine(s);
            Console.Read();
        }

        static void InitCameraService()
        {

        }
    }
}
